//
//  PurchaseTableViewCell.m
//  TenThousand
//
//  Created by 我的 on 16/6/7.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "PurchaseTableViewCell.h"



@implementation PurchaseTableViewCell
{
    NSString *show;
    UILabel *labe;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    CGFloat width = 70;
    _pieChartView = [[PieProgressBar alloc]initWithFrame:CGRectMake(Screen_Width -100, 30, width, width)];
    
    [self.contentView addSubview:_pieChartView];

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


//login按钮设置圆角
-(void)drawRect:(CGRect)rect{
    _promptly.layer.cornerRadius = 3;
    
    
}


- (void)setDataWithModel:(BorrowGetHome *)model
{

    _projectName.text = [NSString stringWithFormat:@"%@   %@",model.ProjectName,model.Code];
    
    [_pieChartView updatePercent:model.Proggress animation:YES];
    _Term.text = [NSString stringWithFormat:@"%@",model.Term];
    
    
    _rate.text = [NSString stringWithFormat:@"%.2f%%",model.Rate ];//预期年化
    _rate.font = [UIFont systemFontOfSize:50.0f];
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:self.rate.text];
    
    //设置字号
    
    [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:25.0f] range:NSMakeRange(self.rate.text.length-3, 3)];
    self.rate.attributedText = str;
    
    
    NSArray *arr = [model.MaxPrice componentsSeparatedByString:@"."];
    if ([arr[0] length] >= 5) {
        NSString *a =     [arr[0] substringToIndex: [arr[0] length] - 4];
        NSRange range1 = NSMakeRange([arr[0] length] - 4, 1);
        show = [NSString stringWithFormat:@"%@.%@万元",a,[arr[0] substringWithRange:range1]];
    }
    if ([arr[0] length] < 5) {
        if (arr.count > 1) {
            show = [NSString stringWithFormat:@"%@.%@元",arr[0],[arr[1] substringToIndex:1]];
        }else{
            show = [NSString stringWithFormat:@"%@元",arr[0]];
        }
    }

    _max.text = [NSString stringWithFormat:@"项目总额:%@",show];
    
}



@end
